/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exterminator.utils;

import exterminator.Main;
import com.jme3.texture.Texture;
import java.util.HashMap;
import java.util.Map;
import tonegod.gui.core.Screen;

/**
 *
 * @author t0neg0d
 */
public class TextureManager {
	public static enum TextureKey {
		ATLAS
	}
	public static enum RegionKey {
		IND_MUCK_AM,
		IND_GAME_AM,
		IND_MUCK_OL,
		IND_GAME_OL,
		BTN_HOSE_U,
		BTN_HOSE_H,
		BTN_HOSE_D,
		BTN_SWAT_U,
		BTN_SWAT_H,
		BTN_SWAT_D,
		BTN_BORDER,
		SPLAT,
		BUG,
		DECK_1,
		DECK_2,
		DECK_3,
		DECK_4,
		SKULL
	}
	private Main main;
	private Screen screen;
	private Map<TextureKey,Texture> textures = new HashMap();
	private Map<RegionKey,String> guiRegions = new HashMap();
	private Map<RegionKey,AnimRegion> animRegions = new HashMap();
	
	public TextureManager(Main main, Screen screen) {
		this.main = main;
		this.screen = screen;
		
		loadTextures();
		loadRegions();
	}
	
	private void loadTextures() {
		Texture tex = screen.createNewTexture("Textures/GameAtlasTest.png");
		tex.setMinFilter(Texture.MinFilter.BilinearNearestMipMap);
		tex.setMagFilter(Texture.MagFilter.Bilinear);
		textures.put(TextureKey.ATLAS, tex);
	}
	
	private void loadRegions() {
		guiRegions.put(RegionKey.IND_MUCK_AM,"x=1|y=1|w=243|h=89");
		guiRegions.put(RegionKey.IND_MUCK_OL,"x=1|y=92|w=243|h=89");
		guiRegions.put(RegionKey.IND_GAME_AM,"x=1|y=185|w=243|h=89");
		guiRegions.put(RegionKey.IND_GAME_OL,"x=1|y=277|w=243|h=89");
		guiRegions.put(RegionKey.BTN_HOSE_U,"x=255|y=96|w=59|h=89");
		guiRegions.put(RegionKey.BTN_HOSE_D,"x=320|y=96|w=59|h=89");
		guiRegions.put(RegionKey.BTN_HOSE_H,"x=385|y=96|w=59|h=89");
		guiRegions.put(RegionKey.BTN_SWAT_U,"x=255|y=1|w=59|h=89");
		guiRegions.put(RegionKey.BTN_SWAT_D,"x=320|y=1|w=59|h=89");
		guiRegions.put(RegionKey.BTN_SWAT_H,"x=385|y=1|w=59|h=89");
		guiRegions.put(RegionKey.BTN_BORDER,"x=143|y=128|w=118|h=79");
		guiRegions.put(RegionKey.SPLAT,"x=4|y=421|w=95|h=86");
		guiRegions.put(RegionKey.BUG,"x=410|y=191|w=100|h=158");
		guiRegions.put(RegionKey.DECK_1,"x=352|y=432|w=80|h=80");
		guiRegions.put(RegionKey.DECK_2,"x=432|y=432|w=80|h=80");
		guiRegions.put(RegionKey.DECK_3,"x=432|y=352|w=80|h=80");
		guiRegions.put(RegionKey.DECK_4,"x=352|y=352|w=80|h=80");
	}
	
	public Texture getTexture(TextureKey key) {
		return textures.get(key);
	}
	
	public String getGUIRegion(RegionKey key) {
		return guiRegions.get(key);
	}
	
	public AnimRegion getAnimRegion(RegionKey key) {
		return animRegions.get(key);
	}
	
	public class AnimRegion {
		public int x = 0, y = 0, w = 0, h = 0;
		public boolean flipY = true;
		
		public AnimRegion(int x, int y, int w, int h) {
			this.x = x;
			this.y = y;
			this.w = w;
			this.h = h;
		}
	}
}
